<template>
    <!-- 
    <b-modal ref="my-modal" hide-footer title="Using Component Methods">
     <div class="d-block text-center">
       <h3>Hello From My Modal!</h3>
     </div>
     <b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button>
     <b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button>
   </b-modal> 
    -->
    <!--
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" title="流程详情" size="xl" hide-footer scrollable no-close-on-backdrop>
        <div class="d-block text-center">
            <!--begin::div-->
            <div class="m-form m-form--fit m-form--label-align-left m-form--group-seperator-dashed">
                <div class="m-portlet__body">
                    <b-card no-body>
                        <b-tabs pills card vertical>
                            <b-tab title="基本信息" active>
                                <b-card-text>
                                    <div class="form-group" style="display:none;">
                                        <label class="col-md-2 col-form-label">流程编号</label>
                                        <div class="col-md-10">
                                            <input class="form-control" type="hidden" v-model="lcProcessForm.id" placeholder="请输入流程编号">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-md-2 col-form-label">标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题</label>
                                        <div class="col-md-6">
                                            <input class="form-control" disabled v-model="lcProcessForm.title" placeholder="请输入">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-lg-2 col-form-label">产&nbsp;品&nbsp;线</label>
                                        <div class="col-md-4">
                                            <select class="form-control" disabled v-model="lcProcessForm.lcProductId" placeholder="请选择">
                                                <option value="">请选择</option>
                                                <option v-for="item in productList" 
                                                    :key="item.id" 
                                                    :label="item.name"
                                                    :value="item.id">
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-lg-2 col-form-label">产&nbsp;品&nbsp;组</label>
                                        <div class="col-md-4">
                                            <select class="form-control" disabled v-model="lcProcessForm.lcGroupId" placeholder="请选择">
                                                <option value="">请选择</option>
                                                <option v-for="item in groupList" 
                                                    :key="item.id" 
                                                    :label="item.name"
                                                    :value="item.id">
                                                </option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-md-2 col-form-label">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</label>
                                        <div class="col-md-2">
                                            <select class="form-control" disabled v-model="lcProcessForm.status" placeholder="请选择">
                                                <option value="">请选择</option>
                                                <option value="0">待发布</option>
                                                <option value="1">发布中</option>
                                                <option value="2">已关闭</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;识</label>
                                        <div class="col-md-3">
                                            <select class="form-control" disabled v-model="lcProcessForm.flag" placeholder="请选择">
                                                <option value="">请选择</option>
                                                <option value="0">通过平台设计器设计</option>
                                                <option value="1">通过上传部署</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-md-2 col-form-label">版&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;本</label>
                                        <div class="col-md-1">
                                            <input class="form-control" readonly disabled v-model="lcProcessForm.version" placeholder="请输入">
                                        </div>
                                    </div>

                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-md-2 col-form-label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</label>
                                        <div class="col-md-8">
                                            <textarea class="form-control" maxlength="800" rows="12" disabled v-model="lcProcessForm.remark">
                                            </textarea>
                                        </div>
                                    </div>
                                </b-card-text>
                            </b-tab>
                            <b-tab title="Bpm规范">
                                <b-card-text>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">Bpmn</label>
                                        <div class="col-md-8">
                                            <textarea class="form-control" style="background: #0a6aa1;color:#fff;" rows="10"
                                                disabled v-model="lcProcessForm.bpmn"></textarea>
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">Graph</label>
                                        <div class="col-md-8">
                                            <textarea class="form-control" style="background: #b94a48;color:#fff;" rows="10"
                                                disabled v-model="lcProcessForm.mxgraphXml"></textarea>
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">image</label>
                                        <div class="col-md-8">
                                            <textarea class="form-control" style="background: #7b7f9e;color:#fff;" rows="10"
                                            disabled v-model="lcProcessForm.imgXml"></textarea>
                                        </div>
                                    </div>
                                </b-card-text>
                            </b-tab>
                            <b-tab title="Bpm属性">
                                <b-card-text>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">宽&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;度</label>
                                        <div class="col-md-2">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.w">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">高&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;度</label>
                                        <div class="col-md-2">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.h">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">线&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;条</label>
                                        <div class="col-md-1 col-form-label">
                                            <div v-if="lcProcessForm.mxgraphStyle == 1">
                                                <b-badge class="mr-1" variant="warning">曲线</b-badge>                                               
                                            </div>
                                            <div v-else>
                                                <b-badge class="mr-1" variant="secondary">直线</b-badge>
                                            </div>
                                        </div>
                                    </div>
                                </b-card-text>
                            </b-tab>
                            <b-tab title="流程信息">
                                <b-card-text>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">模块Key</label>
                                        <div class="col-md-3">
                                            <input class="form-control" disabled v-model="lcProcessForm.moduleKey">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">流程Key</label>
                                        <div class="col-md-3">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.uk">
                                        </div>
                                        <div class="col-md-4">
                                            <div class="alert m-alert m-alert--default" role="alert">
                                                说明：流程Key为流程定义中Key<code>引擎使用</code> .
                                            </div>
                                        </div>

                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">流程UID</label>
                                        <div class="col-md-3">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.uid">
                                        </div>
                                        <div class="col-md-4">
                                            <div class="alert m-alert m-alert--default" role="alert">
                                                说明：流程Uid为流程定义中Uid <code>引擎使用</code> .
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">发&nbsp;起&nbsp;&nbsp;人</label>
                                        <div class="col-md-3">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.candidateStarterUsers">
                                        </div>
                                        <div class="col-md-4">
                                            <div class="alert m-alert m-alert--default" role="alert">
                                                说明：发起人为流程定义中发起人 <code>引擎使用</code> .
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">组&nbsp;类&nbsp;&nbsp;型</label>
                                        <div class="col-lg-2">
                                            <select class="form-control" disabled v-model="lcProcessForm.candidateGroupType"  placeholder="请选择">
                                                <option value="">请选择</option>
                                                <option value="0">部门</option>
                                                <option value="1">岗位</option>
                                                <option value="2">角色</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">按组发起</label>
                                        <div class="col-md-3">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.candidateStarterGroups">
                                        </div>
                                        <div class="col-md-4">
                                            <div class="alert m-alert m-alert--default" role="alert">
                                                说明：按组发起为流程定义中发起组 <code>引擎使用</code> .
                                            </div>
                                        </div>
                                    </div>
                                </b-card-text>
                            </b-tab>
                            <b-tab title="附件">
                                <b-card-text>
                                    <div class="form-group m-form__group row" id="attFile" style="display: none;">
                                        <label class="col-md-2 col-form-label">附&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;件</label>
                                        <div class="col-md-6">
                                            <input class="form-control" type="hidden" disabled v-model="lcProcessForm.attachmentId" >
                                            <img src="/deng/images/default/add_d.png" class="img" width="96" height="96"
                                                id="xt_attachment_pic">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">压&nbsp;&nbsp;缩&nbsp;包</label>
                                        <div class="col-md-3">
                                            <input class="form-control" disabled v-model="lcProcessForm.lcProcessPath">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">路径名称</label>
                                        <div class="col-md-3">
                                            <input class="form-control" disabled v-model="lcProcessForm.lcProcessBpmnPath">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">图片名称</label>
                                        <div class="col-md-3">
                                            <input class="form-control" disabled v-model="lcProcessForm.lcProcessImgPath">
                                        </div>
                                    </div>
                                </b-card-text>
                            </b-tab>
                            <b-tab title="其它">
                                <b-card-text>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">创&nbsp;&nbsp;建&nbsp;人</label>
                                        <div class="col-md-3">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.createBy" placeholder="请输入">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">创建时间</label>
                                        <div class="col-md-3">
                                            <input class="form_datetime form-control" disabled v-model="lcProcessForm.createTime"  placeholder="请选择时间">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">修&nbsp;&nbsp;改&nbsp;人</label>
                                        <div class="col-md-3">
                                            <input class="form-control" type="text" disabled v-model="lcProcessForm.modifiedBy" placeholder="请输入">
                                        </div>
                                    </div>
                                    <div class="form-group m-form__group row">
                                        <label class="col-md-2 col-form-label">修改时间</label>
                                        <div class="col-md-3">
                                            <input class="form_datetime form-control" disabled v-model="lcProcessForm.updateTime" placeholder="请选择时间">
                                        </div>
                                    </div>
                                </b-card-text>
                            </b-tab>
                        </b-tabs>
                </b-card>
                </div>
            </div>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
        </template>
    </b-modal>
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            productList:[],
            groupList:[],
            lcProcessForm: {
                id: "",
                lcProductId:"",
                lcGroupId:"",
                lcGroupId_:"",
                status:"",
                flag:"",
                version:"",
                remark:"",
                bpmn:"",
                mxgraphXml:"",
                imgXml:"",
                w:"",
                h:"",
                mxgraphStyle:"",
                moduleKey:"",
                uk:"",
                uid:"",
                candidateStarterUsers:"",
                candidateGroupType:"",
                candidateStarterGroups:"",
                attachmentId:"",
                path:"",
                bpmnPath:"",
                imgPath:"",
                createBy:"",
                createTime:"",
                modifiedBy:"",
                updateTime:"",
            }
        }
    },
    components: {

    },
    watch: {
        "lcProcessForm.lcProductId":{//监听字段变化
            handler:function(newVal,old){
                this.lcProcessForm.lcGroupId = "";
                if(newVal == "" || newVal == undefined || newVal == null){
                    this.groupList=[];
                }else{
                    this.initGroupList(newVal)
                }
                if(this.lcProcessForm.lcGroupId_ == "" || this.lcProcessForm.lcGroupId_ == undefined || this.lcProcessForm.lcGroupId_ == null){
                    
                }else{
                    this.lcProcessForm.lcGroupId = this.lcProcessForm.lcGroupId_;
                    this.lcProcessForm.lcGroupId_ = "";
                }
            }
        },
    },
    mounted() {

    },
    methods: {
        showModal(id) {
            this.restForm();
            this.$refs['my-modal'].show();            
            this.initProductList();
            this.getDetail(id);
        },
        hideModal() {
            this.$refs['my-modal'].hide()
        },
        toggleModal() {
            // 当模态已隐藏时，我们传递要返回焦点的按钮的ID
            this.$refs['my-modal'].toggle('#toggle-btn')
        },
        restForm() {
            //重置
            Object.assign(this.$data.lcProcessForm, this.$options.data().lcProcessForm);
        },
        initProductList(){
            let params = {};
            apiUtil.post(process.env.VUE_APP_BPM_API + "/lcProduct/find", params).then(({ data }) => {
                this.productList = data.data;
            });
        },
        initGroupList(id){
            let params = {};
            apiUtil.query(process.env.VUE_APP_BPM_API + "/lcGroup/find/"+id, params).then(({ data }) => {
                this.groupList = data.data;
            });
        },
        getDetail(id) {
            apiUtil.get(process.env.VUE_APP_BPM_API + "/lcProcess/get/" + id).then(({ data }) => {
                this.lcProcessForm = data.data;
                this.initGroupList(this.lcProcessForm.lcProductId);
                this.lcProcessForm.lcGroupId_ = data.data.lcGroupId;
            });
        },
    }
}
</script>

<style scoped>
.tab-content {
    padding: 0px 0 0 0;
}

a {
    text-decoration: none;
}

/*正常的未被访问过的链接*/
a:link {
    text-decoration: none;
}

/*已经访问过的链接*/
a:visited {
    text-decoration: none;
}

/*鼠标划过(停留)的链接*/
a:hover {
    text-decoration: none;
}

/* 正在点击的链接*/
a:active {
    text-decoration: none;
}

.nav-tabs-vertical a.active {
    color: #409eff;
    border-right: 1px solid #409eff;
    border-top: 0;
    border-left: 0;
}

.nav-tabs-vertical a,
.user-intro h4,
.user-skill .user-info li h5 {
    margin-bottom: .5rem;
}

.nav-tabs a {
    text-align: left;
    padding: .9rem;
    color: #464a53;
    font-size: 1.1rem;
}

.tab-content {
    padding: 5px 0 0 0;
}

.modal .modal-dialog .close {
    background-color: #fff;
    border: 2px solid #ffffff;
    color: #409eff;
}

.modal-lg {
    max-width: 100%;
    /*width: 75%;*/
    max-width: none;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    box-sizing: border-box;
    list-style: none;
    margin: 0;
    padding: .75rem;
    width: 100%;
}

.tabs-bordered li a.active {
    border-bottom: 2px solid #409eff !important;
}

.card-box {
    padding: 0px;
}</style>